# Readme File for "Social Disruption, Gun-Buying, and Anti-System Beliefs"

By Matthew J. Lacombe, Matthew D. Simonson, Jon Green, James N. Druckman

Please contact [Matthew Simonson](mailto:msimonson@sas.upenn.edu) with questions.

## Requirements

All figures, tables, and calculations for this document were produced using R version 4.1.1. Most of the packages loaded are part of

-   `tidyverse` version 1.3.1,

-   `data.table` version 1.14.2

-   `fixest` version 0.10.4

-   `survey` version 4.1.1

-   `srvyr` version 1.1.1

-   `modelsummary` version 1.0.0

-   `broom` version 1.0.0

All other packages used are essentially for formatting purposes. The submitted version of this paper was produced by running the code was run in RStudio 2022.07.1 on a MacBook Pro running the macOS Monterey 12.5.1 operating system, though it should still run in other environments.

The file you are currently reading is either `Readme.md` or `Readme.html`. The former generates the latter.

## Instructions

1.  Download all files and place them in a separate folder.
2.  Open `social_disruption_gun_buying.Rproj` in RStudio. Running scripts from this R Project helps ensure that the file paths in the code do not need updating.
3.  From RStudio, open `replication.Rmd`. This file is a one-stop shop for producing all tables and figures. It loads data from `lacombe_disruption_data.rds`, a data file containing data from the Covid States Project. The `replication.Rmd` replication file generates tables and figures and saves them to the `tables` and `figures` subdirectories respectively. It saves appendix tables to the `appendix_tables` subdirectory.
4.  You can run individual sections of `replication.Rmd` manually or you can hit the "Knit" button in RStudio to run the whole thing. Doing so will generate an html file `replication.html` which you can ignore.
    a.  Note: Depending on how these files are stored online, there may already be subdirectories, or the figures and tables may all be located in the top level folder alongside all the other files. If there are no subdirectories, running the replication script will create them and populate them with figures and tables (leaving the original figures/tables untouched). If these subdirectories already exist, running the script will replace any tables/figures therein.
5.  To generate the online appendix, open the Rsweave file `online_appendix.Rnw` and hit the "Compile PDF" button in RStudio. The files it loads are located in the `appendix_tables` folder (if no such folder exists, run the replication file first). It will output `online_appendix.pdf`.
    a.  Note that Table A1 is actually generated as a `.png` image and loaded as a graphic; all other appendix tables come from LaTeX files.
    b.  The Rsweave script also generates `online_appendix.tex` and `online_appendix-concordance.tex` as intermediate steps; they can be safely ignored.
6.  The tables which appear in the main text are saved in the `tables_for_main_text.xlsx` excel file, located in the top level directory. The data has been copied by hand from the `table_1.html` and `table_2.html` files. Therefore, running the replication script to re-create these html files will not affect the excel file. This is the only step which is not automated.
